//
//  ProductView.m
//  LearnObjectiveC
//
//  Created by 吴可高 on 16/6/13.
//  Copyright © 2016年 吴可高. All rights reserved.
//

#import "ProductView.h"
#import "ProductCell.h"
#import "ProductHeaderView.h"
@interface ProductView () <UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate>
@property (strong, nonatomic) UITableView * productTableView;
@property (strong, nonatomic) ProductHeaderView * productHeaderView;

@end

@implementation ProductView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUp];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setUp];
    }
    return self;
}

#pragma mark Initialize View Style
-(void)setUp
{
    [self addSubview:self.productTableView];
    [self.productTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 0, 0);
        make.edges.mas_equalTo(self).with.insets(insets);
    }];
}
#pragma mark View Algorithm Processor

#pragma mark Setter Method View Style

#pragma mark Getter Method View Style
-(UITableView *)productTableView
{
    _productTableView = ({
        if (!_productTableView) {
            _productTableView  = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
            _productTableView.delegate   =  self;
            _productTableView.dataSource =  self;
        }
        _productTableView;
    });
    return _productTableView;
}

#pragma mark IBOutlet Action View

#pragma mark Possess  Delegate View（委托代理者）
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ProductCell * cell = [ProductCell productCellWith:tableView];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}
#pragma mark Other Method
-(void)layoutSubviews
{
    [super layoutSubviews];
}
@end
